#include "picture.h"
//1.判断给定argv是否是目录,并读取目录内文件名，找到bmp和jpg格式文件将其存进链表中
int dirpdcz(const char *argv,struct filetupian *head)
{
    struct stat dirinfo;
    stat(argv,&dirinfo);
    if(S_ISDIR(dirinfo.st_mode))
    {
        DIR *dir = opendir(argv);
        //目录结构体
        struct dirent *filename;
        while(1)
        {
            struct filetupian *new; 
            filename = readdir(dir);
            if(filename == NULL)
            {
                printf("目录已经读完!\n");
                closedir(dir);
                break;
            }
            if(tupiangeshi(filename->d_name) == buzhichi)
            {
                printf("格式不支持的文件名:%s\n",filename->d_name);
            }
            if(tupiangeshi(filename->d_name)==bmp || tupiangeshi(filename->d_name)==jpg)
            {
                new = new_node(filename->d_name,tupiangeshi(filename->d_name));
                endc(head,new);
            }

        }
        return 1;
    }
    else
    {
        printf("给定文件不是目录!\n");
        return 0;
    }
}